package com.unytech.watersoil.entity.security;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

import com.unytech.watersoil.entity.BaseObject;
/**
 * 单位实体类
 * @author LONG
 *
 */
@Entity @Table(name="T_UNIT")
@GenericGenerator(name="uuidpk",strategy="uuid")  //这个是Hibernate的主键生成器，换框架的时候，此处应注意
public class Unit extends BaseObject{
	@Id @GeneratedValue(generator="uuidpk")
	@Column(length=18)
	private String unitid;           //单位ID
	
	@Column(length=50,nullable=false)
	private String unitname;         //单位名称
	
	@Column(length=18,nullable=true)
	private String incity;           //所在城市
	
	@Column(length=30,nullable=true)
	private String intelligenceno;   //资质证书号
	
	@Column(nullable=true)
	private Date intelligencenodate; //取得资质时间
	
	@Column(length=50,nullable=true)
	private String approveunit;	     //批准单位
	
	@Column(length=30,nullable=true)
	private String approveno;	     //批准文号
	
	@Column(length=50,nullable=true)
	private String artificialperson; //法人代表
	
	@Column(length=50,nullable=true)
	private String principal;	     //负责人
	
	@Column(length=20)
	private String unitphone;	     //联系电话
	
	@Column(length=20)
	private String unitfax;	         //传真
	
	@Column(length=50)
	private String unitemail;	     //E-mail
	
	@Column(length=15)
	private String postcode;	     //邮编
	
	@Column(length=100,nullable=true)
	private String address;	         //单位地址
	
	@Column(length=50,nullable=true)
	private String approvething;     //考核情况
	
	@ManyToOne(cascade={CascadeType.REFRESH,CascadeType.MERGE}) 
	@JoinColumn(name="user_id")           //外键列名
	private User createperson;       //单位创建人
	
	//级联刷新，级联保存，级联更新；懒加载（一对多关系，多的一方默认就是延迟加载，所以可以不设置fetch；关系被维护端，由User类中的unit字段来维护）
	@OneToMany(cascade={CascadeType.REFRESH,CascadeType.PERSIST,CascadeType.MERGE},fetch=FetchType.LAZY,mappedBy="unit")
	private Set<User> user;          //隶属此单位的用户
	
	public String getUnitid() {
		return unitid;
	}
	public void setUnitid(String unitid) {
		this.unitid = unitid;
	}
	public String getUnitname() {
		return unitname;
	}
	public void setUnitname(String unitname) {
		this.unitname = unitname;
	}
	public String getIncity() {
		return incity;
	}
	public void setIncity(String incity) {
		this.incity = incity;
	}
	public String getIntelligenceno() {
		return intelligenceno;
	}
	public void setIntelligenceno(String intelligenceno) {
		this.intelligenceno = intelligenceno;
	}
	public Date getIntelligencenodate() {
		return intelligencenodate;
	}
	public void setIntelligencenodate(Date intelligencenodate) {
		this.intelligencenodate = intelligencenodate;
	}
	public String getApproveunit() {
		return approveunit;
	}
	public void setApproveunit(String approveunit) {
		this.approveunit = approveunit;
	}
	public String getApproveno() {
		return approveno;
	}
	public void setApproveno(String approveno) {
		this.approveno = approveno;
	}
	public String getArtificialperson() {
		return artificialperson;
	}
	public void setArtificialperson(String artificialperson) {
		this.artificialperson = artificialperson;
	}
	public String getPrincipal() {
		return principal;
	}
	public void setPrincipal(String principal) {
		this.principal = principal;
	}
	public String getUnitphone() {
		return unitphone;
	}
	public void setUnitphone(String unitphone) {
		this.unitphone = unitphone;
	}
	public String getUnitfax() {
		return unitfax;
	}
	public void setUnitfax(String unitfax) {
		this.unitfax = unitfax;
	}
	public String getUnitemail() {
		return unitemail;
	}
	public void setUnitemail(String unitemail) {
		this.unitemail = unitemail;
	}
	public String getPostcode() {
		return postcode;
	}
	public void setPostcode(String postcode) {
		this.postcode = postcode;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getApprovething() {
		return approvething;
	}
	public void setApprovething(String approvething) {
		this.approvething = approvething;
	}
	public Set<User> getUser() {
		return user;
	}
	public void setUser(Set<User> user) {
		this.user = user;
	}	
}
